﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SSISForSAPComponents
{
    public partial class SapDataSourceStaticTableEdit : Form
    {
        System.Data.DataTable _table;
        public SapDataSourceStaticTableEdit()
        {
            InitializeComponent();
        }
        public SapDataSourceStaticTableEdit(System.Data.DataTable table)
            : this()
        {
            _table = table;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this._table.RejectChanges();
            this.Close();
        }

        private void SapDataSourceStaticTableEdit_Load(object sender, EventArgs e)
        {
            try
            {
                this.dataGridView1.DataSource = this._table;
                this.dataGridView1.Refresh();
            }
            catch (Exception ex)
            {
                
                throw;
            }
        }

        private void btnOk_Click(object sender, EventArgs e)
        {

            this._table.AcceptChanges();
            this.Close();
            //List<DataGridViewRow> gridrows = new List<DataGridViewRow>();
            //foreach (DataGridViewRow gdr in this.dataGridView1.Rows)
            //{
            //    gridrows.Add(gdr);


            //}
            //foreach (DataGridViewRow gdr in gridrows)
            //{
            //    DataRow dr = this._table.Rows.Add();
            //    for (int i = 0; i < dr.Table.Columns.Count; i++)
            //    {
            //        dr[dr.Table.Columns[i].ColumnName] = gdr.Cells[dr.Table.Columns[i].ColumnName];
            //    }
            //}
        }

       
    }
}
